<!--
 * @Author: 徐建辰
 * @Date: 2022-06-06 10:00:56
 * @LastEditTime: 2022-06-06 10:05:52
 * @LastEditors: 徐建辰
 * @Description: avatar动画组件
-->
<template>
  <div class="pan-container" :style="style">
    <div class="pan-info">
      <div class="pan-roles">
        <slot />
      </div>
    </div>
    <div :style="{backgroundImage: `url(${image})`}" class="pan-thumb" />
  </div>
</template>

<script setup>
import {computed} from 'vue'

// eslint-disable-next-line
const props = defineProps({
  image: {
    type: String,
  },
  zIndex: {
    type: Number,
    default: 1
  },
  width: {
    type: String,
    default: '150px'
  },
  height: {
    type: String,
    default: '150px'
  }
})

const style = computed(() => {
  const p = props
  return {
    zIndex: p.zIndex,
    width: p.width,
    height: p.height
  }
})
</script>

<style scoped lang="scss">
.pan-container {
  @include wh(200px, 200px);
  @include borderRadius(50%);
  display: inline-block;
  position: relative;
  cursor: default;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .02);
  .pan-info {
    position: absolute;
    width: inherit;
    height: inherit;
    @include borderRadius(50%);
    overflow: hidden;
    box-shadow: inset 0 0 0 5px rgba(0, 0, 0, .05);
    h3 {
      color: $color-text;
      text-transform: uppercase;
      position: relative;
      letter-spacing: 2px;
      font-size: $font-size-medium;
      margin: 0 60px;
      padding: 22px 0 0 0;
      height: 85px;
      font-family: 'Open Sans', Arial, sans-serif;
      text-shadow: 0 0 1px #fff, 0 1px 2px rgba(0, 0, 0, .3);
    }
    p {
      color: $color-text;
      padding: 10px 5px;
      font-style: initial;
      margin: 0 30px;
      font-size: 12px;
      border-top: 1px solid rgba(255, 255, 255, .5);
      a {
        display: block;
        color: $color-text-s;
        height: 80px;
        background: rgba(255, 255, 255, .3);
        @include borderRadius(50%);
        color: $color-text;
        font-style: normal;
        font-weight: 700;
        text-transform: uppercase;
        font-size: 9px;
        letter-spacing: 1px;
        padding-top: 24px;
        margin: 7px auto 0;
        font-family: 'Open Sans', Arial, sans-serif;
        opacity: 0;
        transition: transform .3s ease-in-out .2s, opacity .3s ease-in-out .2s, background .2s linear 0s;
        transform: translateX(60px) rotate(90deg);
        &:hover {
          background: rgba(255, 255, 255, .5);
        }
      }
    }
    .pan-roles {
      padding: 20px;
      text-align: center;
    }
  }
  .pan-thumb {
    @include wh(100%, 100%);
    background-position: center center;
    background-size: cover;
    @include borderRadius(50%);
    overflow: hidden;
    position: absolute;
    transform-origin: 95% 40%;
    transition: all .3s ease-in-out;
    box-shadow: 0 0 28px rgba(24, 144, 255, .15);
  }
}
.pan-container:hover .pan-thumb {
  transform: rotate(-110deg);
}
.pan-thumb:hover .pan-info p a {
  opacity: 1;
  transform: translateX(0px) rotate(0deg);
}
</style>
